from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.database import get_db
from app import models, schemas

router = APIRouter(prefix="/hot-tools", tags=["热门工具"])


@router.get("", response_model=schemas.Response)
async def list_hot_tools(db: Session = Depends(get_db)):
    """获取热门工具列表（从 agents 表中获取 is_hot=1 的智能体）"""
    hot_agents = db.query(models.Agent).filter(
        models.Agent.is_hot == True,
        models.Agent.enabled == True
    ).all()
    
    # 构建返回结果
    result = []
    for agent in hot_agents:
        result.append({
            "id": agent.id,
            "name": agent.name,
            "icon": agent.name[0],  # 简单取首字母作为icon
            "description": agent.description
        })
    
    return schemas.Response(data=result)

